{{template "header"}}
<title>添加文章 - 我的 beego 博客</title>
</head>

<body>
	<div class="container">
		<form method="POST" action="/topic" enctype="multipart/form-data">
			<div class="form-group">
				<label>文章标题：</label>
				<input id="title" class="form-control" placeholder="文章标题" name="title">
			</div>
			<div class="form-group">
				<label>文章分类：</label>
				<input class="form-control" placeholder="文章分类" name="category">
			</div>
			<div class="form-group">
				<label>文章标签：</label>
				<input class="form-control" placeholder="文章标签" name="labels">
			</div>
			<div class="form-group">
				<label>文章内容：</label>
				<textarea id="content" class="form-control" name="content" placeholder="文章内容" cols="30" rows="10"></textarea>
			</div>
			<div class="form-group">
				<label>文章附件：</label>
				<input type="file" class="form-control" name="attachment">
			</div>
			<button type="submit" class="btn btn-default" onclick="return checkInput();">提交</button>
			<button class="btn btn-default" onclick="return backToHome();">返回</button>
		</form>

		<script type="text/javascript">
			function checkInput() {
				if (document.getElementById("title").value.length == 0) {
					alert("请输入文章标题");
					return false
				}
				if (document.getElementById("content").value.length == 0) {
					alert("请输入文章内容");
					return false
				}
				return true
			}
			function backToHome() {
				window.location.href = "/topic"
				return false
			}

		</script>
	</div>
</body>

</html>